<?php

class Application_Form_Mail extends Zend_Form
{
    public function init()
    {
        $this->setName('Mail');
        
        $mail_id = new Zend_Form_Element_Hidden('mail_id');
        $mail_id->addFilter('Int');
        
        $template_id = new Zend_Form_Element_Hidden('template_id');
        $template_id->addFilter('Int');

        $subject = new Zend_Form_Element_Text('subject');
        $subject->setLabel('Tiêu đề')
              ->setRequired(true)
              ->addFilter('StripTags')
              ->addFilter('StringTrim')
              ->addValidator('NotEmpty');
                      
        $content = new Zend_Form_Element_Textarea('content');
        $content->setLabel('Nội dung')
               ->setRequired(true)
               ->addFilter('StripTags')
               ->addFilter('StringTrim')
               ->addValidator('NotEmpty');
              
        $created_user_id = new Zend_Form_Element_Hidden('created_user_id');
        				
        
        $from_mail = new Zend_Form_Element_Text('from_mail');
        $from_mail->setLabel('Mail người gửi')
              ->setRequired(true)
              ->addFilter('StripTags')
              ->addFilter('StringTrim')
              ->addValidator('NotEmpty');
              
        $from_name = new Zend_Form_Element_Text('from_name');
        $from_name->setLabel('Tên người gửi')
              ->setRequired(false)
              ->addFilter('StripTags')
              ->addFilter('StringTrim')
              ->addValidator('NotEmpty');
              
        $reply_to_mail = new Zend_Form_Element_Hidden('reply_to_mail');
        
        $reply_to_name = new Zend_Form_Element_Hidden('reply_to_name');
        
        $to_mail = new Zend_Form_Element_Text('to_mail');
        $to_mail->setLabel('Mail người nhận')
              ->setRequired(true)
              ->addFilter('StripTags')
              ->addFilter('StringTrim')
              ->addValidator('NotEmpty');
              
        $to_name = new Zend_Form_Element_Text('to_name');
        $to_name->setLabel('Tên người nhận')
              ->setRequired(false)
              ->addFilter('StripTags')
              ->addFilter('StringTrim')
              ->addValidator('NotEmpty');
        					  
               
       	$status = new Zend_Form_Element_Select('status');
        $status->setLabel('Trạng thái')
                ->setRequired(true)
                ->addMultiOptions(array(
                 	'sent' => 'Gửi',
                	'outbox' => 'Lưu trữ'
        ));
        
        $created_date = new Zend_Form_Element_Hidden('created_date');
        
        $sent_date = new Zend_Form_Element_Hidden('sent_date');
        
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setAttrib('id', 'submitbutton');
        
        $cancel = new Zend_Form_Element_Submit('cancel');
        $cancel->setAttrib('id', 'cancelbutton');
        
        $this->addElements(array($subject, $content, $from_mail, $from_name, $to_mail, $to_name, $status, $mail_id, $template_id, $created_user_id, $created_date, $sent_date, $submit, $cancel));
    }
}